Skip to content

✨ feat(pricing): surface newly discovered models awaiting price sync - #793

Merged
seakee merged 2 commits into
devfrom
feat/surface-runtime-models-awaiting-price-sync
Sep 16, 2026
Merged

seakee merged 2 commits into
devfrom
feat/surface-runtime-models-awaiting-price-sync

Conversation

@seakee

@seakee seakee commented Sep 16, 2026

Copy link
Copy Markdown
Owner

Summary

Surfaces newly discovered runtime models awaiting price sync across Monitoring, Dashboard, and Usage Analytics with low friction.
Unifies model price attention notifications to indicate that newly discovered models have not yet undergone a price sync check, strictly decoupled from cost calculation logic.

Community and 1.x maintenance PRs must target dev. Approved v2 implementation
PRs target v2. Repository automation retargets other pull requests to dev;
this can change the diff and make existing review comments outdated. main
accepts only a promotion PR whose source is this repository's dev branch.

Scope

  • Frontend panel
  • Manager Server
  • CPA panel mode
  • Full Docker mode
  • Native packages / release
  • Docs / Wiki
  • CI / build / tooling

Changes

  • Manager Server (modelprice):
    • Expose authenticated read-only endpoint GET /v0/management/model-prices/runtime-models to discover runtime models without database writes or external pricing calls.
    • Export public DiscoverRuntimeModels(ctx) and implement RuntimeModelPricingStatus(ctx) with model normalization, sorting, 5s timeout, and unpriced detection against existing prices.
  • Frontend Attention Store (apps/web/src/features/model-price-attention):
    • Add singleton ModelPriceAttentionStore with localStorage isolation (cpamp-model-price-attention-v1) keyed by manager server base URL.
    • Add generation guard to discard stale in-flight responses across connection switches.
    • Immediately reset volatile state (runtimeModels, unpricedModels, pendingModels, loading, lastCheckedAtMs) when the base URL changes, allowing fresh checks on the new connection.
    • Bind attention snapshots to the active manager server scope (ModelPriceAttentionSnapshot) to avoid acknowledging pending models across different environments.
    • Throttle discovery retry attempts to 30 minutes on discovery failure using lastAttemptAtMs, while allowing force: true to bypass throttling.
  • Frontend UI & Pages (apps/web):
    • Add unified ModelPriceAttentionLink component supporting action-bar and inline variants with Amber status dots and tooltips.
    • Wire into MonitoringActionBar, Dashboard UsageMetricsCard, and Usage Analytics UsageSummaryCards.
    • In ModelPricesPage:
      • Support ?filter=missing deep link as an initial selection without locking ongoing tab switching.
      • Display pending count badge on the "Sync Prices" button and pending tags on corresponding rows.
      • Implement resolveAcknowledgedPendingModelsAfterSync: when runtime discovery fails and sync falls back to known models, only acknowledge pendingSnapshot ∩ syncModels to prevent falsely clearing runtime-only pending models.
      • Trigger forced attention re-check in background after saving manual model prices or confirming sync candidates.
  • Internationalization & Testing:
    • Add translations for en, zh-CN, zh-TW, and ru.
    • Add comprehensive unit and integration tests across server and web components.

User Impact

Users will see an amber dot indicator next to "Model Prices" when newly discovered runtime models have not yet been checked for pricing. Clicking the link takes them to the Model Prices page with the missing filter active. Clicking "Sync Prices" executes price discovery and sync, immediately clearing the global indicator once synced.

Compatibility / Runtime Notes

  • CPA panel mode: Reads /v1/models from CPA runtime using the existing 5s timeout and CPA discovery credentials.
  • Manager Server mode: Uses AuthorizePanel to protect the read-only status endpoint.
  • Full Docker / native packages: Fully compatible with existing installations; no database schema changes or migrations required.

Data / Security Notes

No database migration, no secret credentials exposed, and no new background schedulers. The discovery status endpoint is strictly read-only and cached client-side.

Risk / Rollback

Risk level: Low

Rollback notes: Reverting this PR restores previous behavior where newly discovered models do not trigger proactive sync attention. No database migrations to undo.

Verification

  • Type check
  • Lint
  • Tests
  • Build
  • Manual UI check
  • Docs/link check
  • Not applicable, docs-only

Commands / evidence:

npm run manager-server:test (all packages passed)
go test -count=1 ./internal/service/modelprice/... ./internal/http/controller/modelprice/... (passed)
npm run test:web (232 files, 3528 tests passed)
npm run type-check (tsc --noEmit passed, 0 errors)
npm run lint (eslint passed, 0 errors, 0 new warnings)
npm run build (singlefile dist/index.html generated)
npm run check:demo-isolation (passed)
npm run build:demo (dist-demo/index.html generated)
npm run test:repo (15 files, 235 tests passed)
git diff --check (passed, clean)

Screenshots / Recordings

N/A (covered by comprehensive unit and integration tests)

Docs

  • README / README_CN updated for user-visible capabilities
  • Matching docs manual and navigation updated
  • Demo fixtures, screenshots, and deep links reviewed
  • Release notes needed
  • Not needed — explanation included below

Docs decision: Internal UI feature addition; release notes will be generated automatically during standard release flow.

Related

Refs #515
Refs #792

Add read-only runtime model pricing status endpoint in manager-server and low-friction model price attention notifications across Monitoring, Dashboard, and Usage Analytics.

- manager-server: expose GET /v0/management/model-prices/runtime-models to discover unpriced models from CPA runtime without mutating database or calling external pricing sources
- web: add modelPriceAttention store with localStorage isolation, 30m cache, and tab-focus refresh
- web: add unified ModelPriceAttentionLink component and wire into MonitoringActionBar, Dashboard UsageMetricsCard, and Usage Analytics
- web: update ModelPricesPage to support ?filter=missing, display pending sync badge, and acknowledge attention on sync
- tests: add end-to-end unit and integration tests across server and web
…acknowledgment, and deep-link filter

- only acknowledge pending models that actually participated in fallback sync
- add scope generation guard against cross-connection races and stale in-flight responses
- bind attention snapshots to manager server scope
- throttle failed discovery retry attempts to 30 minutes
- decouple ?filter=missing from ongoing tab selection in ModelPricesPage
- trigger background forced attention re-check after saving manual model price
- add regression tests covering fallback acknowledgment, scope switches, and throttle
@seakee
seakee merged commit 0a0fb06 into dev Sep 16, 2026
13 of 20 checks passed
@seakee
seakee deleted the feat/surface-runtime-models-awaiting-price-sync branch September 16, 2026 16:33
Link-Start pushed a commit to Link-Start/CPA-Manager-Plus_seakee that referenced this pull request Sep 17, 2026
…card ownership

PR seakee#793 introduced global model price attention across Monitoring, Dashboard, and Usage Analytics. However, the inline variant rendered variable-length localized text, causing container overflow and truncated titles in high-density cards across different languages. Additionally, UsageSummaryCardView implicitly tied attention visibility to icon === 'cost', leaking alerts into shared components (e.g. Accounts Overview) and creating duplicate attention indicators when multiple cost cards were present.

- Lock ModelPriceAttentionLink inline variant to a fixed 24x24px footprint using IconDollarSign with a compact absolute-positioned amber attention dot.
- Remove visible localized label text from the inline variant while preserving full tooltip and aria-label semantic attributes.
- Keep Monitoring action-bar variant layout and localized label unchanged.
- Decouple attention visibility from icon === 'cost' by adding explicit showModelPriceAttention?: boolean to UsageSummaryCard.
- Designate exactly one primary cost card per Usage Analytics summary group as the attention owner, eliminating duplicate indicators.
- Add flex: 0 0 auto defense on attention containers in Dashboard and Usage Analytics to prevent flex compression across viewport breakpoints.
- Update and expand unit, integration, and builder test suites.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant